const quickSort = (src) => {
    const arr = [...src];
    if(arr.length < 2){
        return arr;           
    }else{
        const pivot = arr.pop();
        const {greaterThanPivot, lessThanPiovt} = splitArrByPiovt(arr, pivot);
        return [...quickSort(lessThanPiovt), pivot, ...quickSort(greaterThanPivot)];
    }
}

const splitArrByPiovt = (arr, piovt) => {
    const greaterThanPivot = [];
    const lessThanPiovt = [];
    arr.forEach(ele => {
        if(ele > piovt){
            greaterThanPivot.push(ele);
        }else{
            lessThanPiovt.push(ele);
        }
    });
    return {greaterThanPivot, lessThanPiovt};
}